home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Panorama / Panorama - Disk 01 (1986-02-15)(Pacific North-West Amigas Club)[h AFL][b corrupt files].zip / Panorama - Disk 01 (1986-02-15)(Pacific North-West Amigas Club)[h AFL][b corrupt files].adf / timing.h < prev   
Text File  |  1989-10-24  |  1KB  |  43 lines

  1.    /*
  2.          timing.h
  3.  
  4.           Two routines, timein() and timeout() can be used as a
  5.       general-purpose timer for  benchmarks, etc.
  6.           timein() notes the time when called.
  7.           timeout() computes the elapsed time in 1/50 secs and prints the
  8.       result in seconds, to the nearest tenth.
  9.           Having called timein(), timeout() may be called as many times
  10.       as you like, always computing and printing the time since
  11.       the last specified timein().
  12.           A new timing point may be specified any time with timein().
  13.           These routines are accurate as long as a day boundary isn't crossed.
  14.                          Steve Allen
  15.      */
  16.  
  17.  static int startime[3], endtime[3]; /* days, minutes, tick in minute (3000) */
  18.  
  19.  void timein()
  20.   {
  21.    DateStamp(startime);       /* System call */
  22.   }
  23.  
  24.  void timeout()
  25.  
  26.  {
  27.   int secs, tenths, x;
  28.  
  29.   DateStamp(endtime);          /* System call */
  30.  
  31.   for (x=0; x<3; ++x)
  32.     endtime[x] -= startime[x];
  33.  
  34.   if (endtime[1])                    /* did minutes change? */
  35.    endtime[2] += (endtime[1]* 3000); /* add ticks_per_minute to secs */
  36.  
  37.   secs = endtime[2]/50;
  38.   tenths = (endtime[2]%50)/5;
  39.  
  40.   printf("Elapsed Time: %d.%d seconds.\n",secs,tenths);
  41.  }
  42.  
  43.